from flask import Blueprint

def create_api_blueprint(upload_dao, task_dao, preview_dao, preset_dao,
                         task_manager, file_manager, preview_manager):
    """创建API蓝图"""

    # 创建主API蓝图
    api = Blueprint('api', __name__, url_prefix='/api')

    # 导入各个子模块的路由
    from .upload_routes import create_upload_routes
    from .library_routes import create_library_routes
    from .preview_routes import create_preview_routes
    from .task_routes import create_task_routes
    from .history_routes import create_history_routes
    from .preset_routes import create_preset_routes
    from .system_routes import create_system_routes
    from .training_routes import create_training_routes

    # 注册各个子路由
    upload_routes = create_upload_routes(upload_dao, file_manager)
    library_routes = create_library_routes(upload_dao, file_manager)
    preview_routes = create_preview_routes(preview_dao, preview_manager)
    task_routes = create_task_routes(task_dao, upload_dao, task_manager)
    history_routes = create_history_routes(task_dao)
    preset_routes = create_preset_routes(preset_dao)
    system_routes = create_system_routes(file_manager, preview_manager, task_manager)
    training_bp = create_training_routes(task_dao)

    # 注册蓝图
    api.register_blueprint(upload_routes)
    api.register_blueprint(library_routes)
    api.register_blueprint(preview_routes)
    api.register_blueprint(task_routes)
    api.register_blueprint(history_routes)
    api.register_blueprint(preset_routes)
    api.register_blueprint(system_routes)
    api.register_blueprint(training_bp)

    return api